//
//  FatherViewController.m
//  UI-豆瓣项目APP
//
//  Created by liuxin on 15/11/4.
//  Copyright © 2015年 孙鹏. All rights reserved.
//

#import "FatherViewController.h"
#import "MovieListViewController.h"
#import "MovieMapViewController.h"
@interface FatherViewController ()
@property(nonatomic,retain)MovieListViewController *movieList;
@property(nonatomic,retain)MovieMapViewController *movieMap;
@end

@implementation FatherViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"电影";
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bg_nav"] forBarMetrics:UIBarMetricsDefault];
    UIImage *rightImage = [UIImage imageNamed:@"btn_nav_collection@2x"];
    rightImage = [rightImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:rightImage style:UIBarButtonItemStylePlain  target:self action:@selector(rightAction:)];

    self.movieMap = [MovieMapViewController new];
    [self addChildViewController:self.movieMap];
    [self.view addSubview:self.movieMap.view];
    
    self.movieList = [MovieListViewController new];
    [self addChildViewController:self.movieList];
    [self.view addSubview:self.movieList.view];
    
}
-(void)rightAction:(UIBarButtonItem *)btn{
    static BOOL state = YES;
    if(state){
        btn.image = [UIImage imageNamed:@"btn_nav_list@2x"];
        [UIView transitionFromView:self.movieList.view toView:self.movieMap.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
        }];
    }else{
        btn.image = [UIImage imageNamed:@"btn_nav_collection@2x"];
        [UIView transitionFromView:self.movieMap.view toView:self.movieList.view duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {
        }];
    }
    state = !state;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
